package nl.depository.pim;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.tapestry5.ValueEncoder;

public class ObjectValueEncoder implements ValueEncoder<Object>
{
	private Map<String, Object> lookup = new HashMap<String, Object>();
	
	private int counter;
	
	public String toClient(Object value)
	{
		String key = Integer.toString(counter++);
		lookup.put(key, value);
		return key;
	}

	public Object toValue(String clientValue)
	{
		return lookup.get(clientValue);
	}
	
	public List<Object> toList()
	{
		return (List<Object>) lookup.values();
	}
}
